package cn.itcast.controller;

import cn.itcast.feign.client.RoomClient;
import cn.itcast.feign.client.UserClient;
import cn.itcast.feign.pojo.*;
import cn.itcast.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/orders")
public class OrderController {
    @Autowired
    private OrderService orderService;


    @GetMapping("/{orderId}")
    public Order getOrderById(@PathVariable Integer orderId) {
        return orderService.getOrderById(orderId);
    }

    @PostMapping("/")
    public void createOrder(@RequestBody Order order) {
        orderService.createOrder(order);
    }

    @GetMapping("/")
    public PageBean getOrders(@RequestParam String userName, @RequestParam Integer roomPrice, @RequestParam Date startDate, @RequestParam Date endDate, @RequestParam Integer page, @RequestParam Integer pageSize) {
        return orderService.getOrdersByIdCardAndRoomNumberAndDateRange(userName, roomPrice, startDate, endDate, page, pageSize);
    }
}
